function main( ui,json) {

  //return json;
  var json = ui.getQueryParameters().getFirst("json");
  if ( json == null ){
        var ex = "{ exception: { message: 'no param provided'} }";
        return ex;
  }
  var jsonObject = new JSONObject( json );
  
  
  return checkUser( jsonObject );
}


function checkUser(jsonObject) {
  
  var records = new JSONArray();
  var cmd = "select t from UserEntity t where t.userId =:userId"
    EntityManager.find(  
    cmd,  
    jsonObject,
     function(result) {
      
      for( var i = 0; i < result.size() ; ++i ) {
        
        records.put( JSONObject.wrap(result.get(i)) );
      }
      
    });
    
    
  var result = records.length() > 0 ? "OK" : "KO";
    
   
    

    return result;

}